package 代码记录.指定公司代码练习记录.华为_2024.分值100;

import java.util.Scanner;

/**
 * @author zx
 * @create 2024-02-02 20:06
 * 自己做不出来，看懂了人家的题解
 */
public class 虚拟游戏理财_24 {
    /**
     * 评论区说是：总产品数为1和只投资一个产品情况没考虑(小问题)
     */
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int totalAmount = sc.nextInt();
        int X = sc.nextInt();

        int[] returnRateLst = new int[n];
        int[] riskLst = new int[n];
        int[] maxAmountLst = new int[n];

        for (int i = 0; i < n; i++) {
            returnRateLst[i] = sc.nextInt();
        }
        for (int i = 0; i < n; i++) {
            riskLst[i] = sc.nextInt();
        }
        for (int i = 0; i < n; i++) {
            maxAmountLst[i] = sc.nextInt();
        }
        int maxReturn = 0;
        int[][] pairs = new int[2][2];
        for (int i = 0; i < n; i++) {
            for (int j = i + 1; j < n; j++) {
                if (riskLst[i] + riskLst[j] > X) {
                    continue;
                }
                int iAmount = 0, jAmount = 0;
                if (maxAmountLst[i] + maxAmountLst[j] <= totalAmount) {
                    iAmount = maxAmountLst[i];
                    jAmount = maxAmountLst[j];
                } else {//i和j中选择单份份额回报率更高的产品
                    if (returnRateLst[i] >= returnRateLst[j]) {
                        iAmount = Math.min(maxAmountLst[i], totalAmount);
                        jAmount = totalAmount - iAmount;
                    } else {
                        jAmount = Math.min(maxAmountLst[j], totalAmount);
                        iAmount = totalAmount - jAmount;
                    }
                }
                //根据选择的i和j，计算当前回报值curReturn
                int curReturn = iAmount * returnRateLst[i] + jAmount * returnRateLst[j];
                //更新全局最大回报值
                if (curReturn > maxReturn) {
                    maxReturn = curReturn;
                    pairs[0][0] = i;
                    pairs[0][1] = iAmount;
                    pairs[1][0] = j;
                    pairs[1][1] = jAmount;
                }
            }
        }
        int[] res = new int[n];
        res[pairs[0][0]] = pairs[0][1];
        res[pairs[1][0]] = pairs[1][1];
        for (int i = 0; i < n; i++) {
            System.out.print(res[i] + " ");
        }
    }
}
